package pack0829;


import java.util.Date;
import java.util.TreeSet;

public class DemoA {
    //TreeSte 添加，删除，长度
    public static void a(){
        TreeSet<Integer> set = new TreeSet<>();
        set.add(65);
        set.add(45);
        set.add(23);
        set.add(43);
        System.out.println(set);
        set.remove(23);
        System.out.println(set);
        int i = set.size();
        System.out.println(i);
    }
    //TreeSet 的遍历
    public static void b(){
        TreeSet<Integer> set = new TreeSet<>();
        set.add(65);
        set.add(45);
        set.add(23);
        set.add(43);
        set.add(34);
        set.add(36);
        for (Integer i: set){
            System.out.println(i);
        }
    }
    //TreeSet 自定义的类型的遍历
    public static void c1(){
        TreeSet<Dept> set = new TreeSet<>();
        Dept d1 = new Dept(1,"aa","e");
        Dept d2 = new Dept(2,"bb","r");
        Dept d3 = new Dept(3,"cc","e");
        set.add(d1);
        set.add(d2);
        set.add(d3);
        System.out.println(set);
    }
    //TreeSet 自定义的类型的比较
    public static void c2(){
        TreeSet<Dept> set = new TreeSet<>();
        Dept d1 = new Dept(1,"a","aa");
        Dept d2 = new Dept(2,"b","bb");
        Dept d3 = new Dept(3,"c","cc");
        set.add(d1);
        set.add(d2);
        set.add(d3);
        Dept d4 = new Dept(3,"c","cc");
        boolean b = set.contains(d4);
        System.out.println(b);
    }

    public static void main(String[] args) {
        c1();
    }
}
